package com.ruoyi.api.rabbitMQ2;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author ywh
 * @date 2021/5/26
 * @desc
 */
@Component
public class MessageSend {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(String msg) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        rabbitTemplate.convertAndSend("ueEdu_delay_ttl_exchange","ueEdu_delay_ttl_key", msg);

        System.out.println(sdf.format(new Date())+":发送消息:"+msg);

    }
}

